Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/stm32f4discovery: default to stdio via CDC ACM #19259

Merged
merged 2 commits into from
Feb 10, 2023

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Feb 7, 2023

Contribution description

Looks like stm32f4discovery also has one of the old on-board ST-Links that don't implement a USB-UART interface (like on stm32f429i-disco).
Since wiring up a USB-UART interface manually is annoying and the board provides a micro-USB port, default to stdio_cdc_acm so the user only needs an extra USB cable to access the shell.

Testing procedure

Connect a micro-USB cable to he port of the stm32f4discovery.
It should be recognized as a CDC ACM interface and make term should automatically connect to it.

I don't have this board.

Issues/PRs references

#19248 (comment)

@github-actions github-actions bot added Area: boards Area: Board ports Area: doc Area: Documentation labels Feb 7, 2023
@benpicco benpicco added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 7, 2023
@riot-ci
Copy link

riot-ci commented Feb 7, 2023

Murdock results

✔️ PASSED

1cd2c16 tests/xtimer_now{32, 64}: blacklist stm32f4discovery

Success Failures Total Runtime
555 0 555 02m:53s

Artifacts

boards/stm32f4discovery/doc.txt Outdated Show resolved Hide resolved
@@ -0,0 +1,3 @@
CONFIG_MODULE_USBUS=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this will cause a problem when compiling tinyUSB apps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I just copied that from stm32f429i-disco, not sure how this could be done better in Kconfig.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST_KCONFIG=1 BOARD=stm32f4discovery make -C tests/pkg_tinyusb_cdc_msc info-modules
=== [ATTENTION] Testing Kconfig dependency modelling ===
[genconfig.py]:ERROR-=> The choice MODULE_STDIO_CDC_ACM (defined at /home/gs/src/RIOT-Xtensa-ESP.esp-idf-4.4/sys/usb/usbus/cdc/acm/Kconfig:57) was selected but was not set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also problems with stm32f429i-disco. Maybe they are not compiled with TEST_KCONFIG=1 in CI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the reason why enabling the tinyusb_device feature for boards with a single USB interface doesn't work and why PR #18998 which tried to enable tinyusb_device for all such boards hangs since 3 months.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the problem in Kconfig could be solved for the moment as in boards/esp32s3-pros3/Kconfig by overriding the default settings in STDIO_IMPLEMENTATION.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choice STDIO_IMPLEMENTATION
    bool "STDIO implementation"
    depends on TEST_KCONFIG
    default MODULE_STDIO_CDC_ACM if MODULE_USBUS
    default MODULE_STDIO_TINYUSB_CDC_ACM if MODULE_TINYUSB_DEVICE
endchoice

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Feb 7, 2023
@benpicco benpicco force-pushed the boards/stm32f4discovery-cdc_acm branch 2 times, most recently from 5448d0f to a1ec273 Compare February 7, 2023 22:24
@github-actions github-actions bot added the Area: Kconfig Area: Kconfig integration label Feb 7, 2023
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 7, 2023
@gschorcht
Copy link
Contributor

bors try

bors bot added a commit that referenced this pull request Feb 8, 2023
Copy link
Contributor

@gschorcht gschorcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets try it with that config.

@bors
Copy link
Contributor

bors bot commented Feb 8, 2023

try

Build succeeded:

@aabadie
Copy link
Contributor

aabadie commented Feb 8, 2023

I used to have this board and iirc the UART was available via stlink. I think some people in Berlin or Hamburg have it for testing.
Also note that there's a new "disc1" version of that board, so the "discovery" is no longer available I think

@gschorcht
Copy link
Contributor

I used to have this board and iirc the UART was available via stlink. I think some people in Berlin or Hamburg have it for testing.
Also note that there's a new "disc1" version of that board, so the "discovery" is no longer available I think

I see. So we should have the same hack as with stm32f429i-disco and stm32f429-disc1.

@benpicco
Copy link
Contributor Author

benpicco commented Feb 8, 2023

Ok so the new version is called stm32f407g-disc1.
Should we rename this board and add a stm32f4discovery that then includes the new board but with the added CDC ACM STDIO module?

I reckon the UART to the ST-Link on the new board is already configured correctly if you have it.

@gschorcht
Copy link
Contributor

gschorcht commented Feb 9, 2023

Ok so the new version is called stm32f407g-disc1.
Should we rename this board and add a stm32f4discovery that then includes the new board but with the added CDC ACM STDIO module?

I think we can stop the discussion about renaming. While writing this comment, I realized that my board is already that new version. While looking for the USART pins used for ST-LINK connection I had to realize that there is still no connection.

ST_LINK_V2_STM32F407G_DISC1_REVE01

For comparison the ST-LINK connection of STM32F429i-DISC1 looks like.

ST_LINK_V2_STM32F429I_DISC1_REVE01

@gschorcht
Copy link
Contributor

gschorcht commented Feb 9, 2023

From the current UM for STM32F407G-DISC1:

UM_STM32F407G_DISC1_REVE01

@gschorcht
Copy link
Contributor

gschorcht commented Feb 9, 2023

@benpicco The following changes solve the default selection problem of the STDIO backend in Kconfig. The boards/stm32f4discovery/stm32f4discovery.config is no longer used so that the STDIO backend selection also works with TEST_KCONFIG=1 for tinyusb which doesn't if the configuration is hard-coded by the boards/stm32f4discovery/stm32f4discovery.config file. I have tested it for non-USB application as well as for a tinyUSB application and an USBUS application with a temporary tests/usbus_hid/app.config.test.

diff --git a/boards/stm32f4discovery/Kconfig b/boards/stm32f4discovery/Kconfig
index 9a006f678d..39e929f976 100644
--- a/boards/stm32f4discovery/Kconfig
+++ b/boards/stm32f4discovery/Kconfig
@@ -35,6 +35,14 @@ config BOARD_STM32F4DISCOVERY
 
     select HAVE_SAUL_GPIO
 
+    select MODULE_USBUS_CDC_ACM if TEST_KCONFIG && !PACKAGE_TINYUSB
+    select PACKAGE_TINYUSB if TEST_KCONFIG && !MODULE_USBUS
+
+choice STDIO_IMPLEMENTATION
+    default MODULE_STDIO_CDC_ACM if MODULE_USBUS
+    default MODULE_STDIO_TINYUSB_CDC_ACM if PACKAGE_TINYUSB
+endchoice
+
 source "$(RIOTBOARD)/common/stm32/Kconfig"
 
 config ERROR_MODULES_CONFLICT
diff --git a/boards/stm32f4discovery/stm32f4discovery.config b/boards/stm32f4discovery/stm32f4discovery.config
deleted file mode 100644
index 7699f35a5c..0000000000
--- a/boards/stm32f4discovery/stm32f4discovery.config
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_MODULE_USBUS=y
-CONFIG_MODULE_USBUS_CDC_ACM=y
-CONFIG_MODULE_STDIO_CDC_ACM=y

@gschorcht
Copy link
Contributor

gschorcht commented Feb 9, 2023

From the current UM for STM32F407G-DISC1:

UM_STM32F407G_DISC1_REVE01

This is quite frustrating. What sense does the VCOM make if the pins are not hard-wired?

@gschorcht
Copy link
Contributor

Please squash.

@benpicco benpicco force-pushed the boards/stm32f4discovery-cdc_acm branch from 31fa60c to b31ec28 Compare February 9, 2023 16:50
@benpicco
Copy link
Contributor Author

benpicco commented Feb 9, 2023

Uh but looks like Kconfig is not happy.

@benpicco benpicco force-pushed the boards/stm32f4discovery-cdc_acm branch from b31ec28 to c57ff38 Compare February 9, 2023 17:00
@benpicco
Copy link
Contributor Author

benpicco commented Feb 9, 2023

I went back to the original solution as at least that one is accepted by CI.

@gschorcht
Copy link
Contributor

gschorcht commented Feb 9, 2023

I went back to the original solution as at least that one is accepted by CI.

But this is a wrong picture. Once you try to compile any tinyUSB app with TEST_KCONFIG=1, you will run into a problem. I tested selected modules with tests/shell, tests/pkg_tinyusb_cdc_acm and tests/usbus_hid and a temporary tests/usbus_hid/app.config.text without problems. Let me check the examples/hello_world problem.

@gschorcht
Copy link
Contributor

The problem is that `boards/stm32f4discovery/stm32f4discovery.config hard codes the USBUS CDC ACM interface. IMHO, the problem is of course the wrong modelling approach of STDIO backends in Kconfig and I really hope we can solve it.

Copy link
Contributor

@gschorcht gschorcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chaned to Request changes to avoid an accidental merge as long as I investigate the Kconfig problem.

@gschorcht
Copy link
Contributor

Could you try the following please?

diff --git a/boards/stm32f4discovery/Kconfig b/boards/stm32f4discovery/Kconfig
index 9a006f678d..e405c8b46f 100644
--- a/boards/stm32f4discovery/Kconfig
+++ b/boards/stm32f4discovery/Kconfig
@@ -35,6 +35,14 @@ config BOARD_STM32F4DISCOVERY
 
     select HAVE_SAUL_GPIO
 
+    select MODULE_USBUS if TEST_KCONFIG && !PACKAGE_TINYUSB
+    select MODULE_USBUS_CDC_ACM if TEST_KCONFIG && !PACKAGE_TINYUSB
+
+choice STDIO_IMPLEMENTATION
+    default MODULE_STDIO_CDC_ACM if MODULE_USBUS
+    default MODULE_STDIO_TINYUSB_CDC_ACM if PACKAGE_TINYUSB
+endchoice
+
 source "$(RIOTBOARD)/common/stm32/Kconfig"
 
 config ERROR_MODULES_CONFLICT
diff --git a/boards/stm32f4discovery/stm32f4discovery.config b/boards/stm32f4discovery/stm32f4discovery.config
deleted file mode 100644
index 7699f35a5c..0000000000
--- a/boards/stm32f4discovery/stm32f4discovery.config
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_MODULE_USBUS=y
-CONFIG_MODULE_USBUS_CDC_ACM=y
-CONFIG_MODULE_STDIO_CDC_ACM=y

Using MODULE_STDIO_TINYUSB_CDC_ACM when PACKAGE_TINYUSB is enabled for some reason is sufficient to select all tinyusb_* modules that are needed, since the dependency logic for tinyUSB is modeled as in makefiles, i.e. if MODULE_STDIO_TINYUSB_CDC_ACM is used, all needed modules will be pulled enabled.

I wished it would be the same for MODULE_STDIO_CDC_ACM but the logic is inverse. The user has first to enable MODULE_USUSB, then MODULE_USBUS_CDC_ACM becomes visible and can be enabled and afterwards MODULE_STDIO_CDC_ACM becomes visible and can be enabled. Thats why the USBUS module have to be selected explicitly in board description. This approach make sense for optional modules but doesn't make sense in case of STDIO default backend selection. I hope this will change.

@gschorcht
Copy link
Contributor

With these changes, the board should use MODULE_STDIO_CDC_ACM by default if tinyUSB is not used. In fact the same as using boards/stm32f4discovery/stm32f4discovery.config but it allows also to use tinyUSB.

@benpicco
Copy link
Contributor Author

benpicco commented Feb 9, 2023

Thank you, CI seems to like this one.

@gschorcht
Copy link
Contributor

Please squash.

@benpicco benpicco force-pushed the boards/stm32f4discovery-cdc_acm branch from e42c85d to 1cd2c16 Compare February 10, 2023 09:12
@benpicco
Copy link
Contributor Author

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 10, 2023

Build succeeded:

@bors bors bot merged commit d145a87 into RIOT-OS:master Feb 10, 2023
@benpicco benpicco deleted the boards/stm32f4discovery-cdc_acm branch February 10, 2023 11:17
@MrKevinWeiss MrKevinWeiss added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants